﻿using System.Windows.Forms;

namespace Z.IconLibraryGenerator.WinForm
{
    public partial class ProjectConfiguration
    {
        public bool Save()
        {
            if (string.IsNullOrEmpty(SaveFile))
            {
                var dlg = new SaveFileDialog();
                dlg.Filter = @"Icon Project Generator files (*.zicongen)|*.zicongen|All files (*.*)|*.*";
                dlg.InitialDirectory = @"C:\";
                dlg.Title = @"Save IconLibraryGenerator Project";

                if (dlg.ShowDialog() == DialogResult.OK)
                {
                    SaveFile = dlg.FileName;
                    string file = dlg.FileName;
                    this.SerializeXml().SaveAs(file);
                    return true;
                }
            }
            else
            {
                this.SerializeXml().SaveAs(SaveFile);
                return true;
            }

            return false;
        }
    }
}